<!DOCTYPE html>
<html class="no-js" lang="zh_CN">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <title>${system_admin_title}</title>
    #required_css
</head>
<body>
#loading
<div class="app $!layout">
    <!-- 头部菜单 -->
    #header
    <section class="layout">
        <!-- 菜单 -->
        #sidebar
        <!-- 内容主体 -->
        <section class="container">
            <section class="main-content">
                <!-- 主体操作栏 -->
                <header class="header navbar">
                    <!-- 左按钮区 -->
                    <div class="btn-group tool-button">
                        <div class="btn-group navbar-btn">
                            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><i class="ti-plus"></i>
                                #springMessage('system.common.add')数据源 <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="$!basePath/bi/datasource/add" data-tabs-link>添加数据源</a></li>
                                <li><a href="$!basePath/bi/datasource/virtual/add" data-tabs-link>添加虚拟数据源</a></li>
                            </ul>
                        </div>
                        <a href="$!basePath/bi/database" class="btn btn-primary navbar-btn" data-tabs-link><i class="ti-server"></i> 外部数据库管理</a>
                    </div>
                    <div class="pull-right offscreen-right">
                    </div>
                </header>
                <div class="content-wrap">
                    <div class="wrapper">
                        <form id="biDatasourceForm" action="$!basePath/bi/datasource" method="post">
                            <div class="row">
                                <div class="col-lg-12 table-responsive">
                                    <table id="biDatasourceTable" class="table no-m">
                                        <thead>
                                        <tr>
                                            <th class="col-md-1">序号</th>
                                            <th class="col-md-3">数据源名称</th>
                                            <th class="col-md-2">标签</th>
                                            <th class="col-md-2">查看数据</th>
                                            <th class="col-md-2">创建时间</th>
                                            <th>#springMessage('system.common.op')</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        #foreach($obj in $list)
                                        <tr>
                                            <td>$!velocityCount</td>
                                            <td>
                                                $!obj.name
                                            </td>
                                            <td>
                                                #if($!obj.db != "local")
                                                <a href="javascript:;" onclick="ns.view.showModal('$!basePath/bi/database/detail/$!obj.db')">
                                                    <span class="label bg-primary">外部</span>
                                                </a>
                                                #else
                                                    <span class="label bg-primary">本地</span>
                                                #end
                                                #if($!obj.isVirtuald())
                                                <span class="label bg-primary">虚拟</span>
                                                #end
                                            </td>
                                            <td>
                                                <a class="text-primary text-underline" href="$!basePath/bi/datasource/view/html/$!obj.id" target="_blank">HTML</a>/
                                                <a class="text-primary text-underline" href="$!basePath/bi/datasource/view/json/$!obj.id" target="_blank">JSON</a>/
                                                <a class="text-primary text-underline" href="$!basePath/bi/datasource/view/xml/$!obj.id" target="_blank">XML</a>
                                            </td>
                                            <td>$!obj.createTime</td>
                                            <td>
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-default btn-xs dropdown-toggle"
                                                            data-toggle="dropdown">
                                                        <i class="ti-settings"></i>
                                                        <span class="ti-angle-down"></span>
                                                    </button>
                                                    <ul class="dropdown-menu" role="menu">
                                                        <li><a href="javascript:;" onclick="ns.view.showModal('$!basePath/bi/datasource/detail/$!obj.id')">查看详情</a></li>
                                                        <li><a href="javascript:;" onclick="del('${obj.id}')">#springMessage('system.common.delete')</a></li>
                                                        <!--<li class="divider"></li>-->
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr>
                                        #end
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-12">
                                    #pager_ajax
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <a class="exit-offscreen"></a>
            </section>
        </section>
    </section>
</div>
#required_js
<!-- 页面组件脚本 -->

<!-- 本页面脚本 -->
<script src="$!basePath/framework/js/view/toast.js"></script>
<script type="text/javascript">
    function del(id) {
        ns.tip.confirm("确定删除吗？", function () {
            ns.post("$!basePath/bi/datasource/delete/" + id, {}, function (success, data) {
                if (success) {
                    ns.back("$!basePath/bi/datasource", 1000);
                } else {
                    ns.tip.toast.error(data.error);
                }
            });
        });
    }
</script>
#loading_close
</body>
</html>
